package class202204._21_25;

/**
 * 子类和父类中的成员不重名的时候
 */

class Base{
    public int a =1;
    public int b = 2;


    public void method(){
        System.out.println("BASE::TEST");
    }

}
class Derived extends Base {
    public int a = 3;
    public  int d = 4;

    public void method(int a){
        System.out.println("BASE::TEST");
    }

    public void method2(){
        System.out.println("Derived::method2()");
    }

    public  void test(){
        method2();
        method();
        /*System.out.println(a);//如果重名了  优先访问子类自己的
        System.out.println(this.b);
        System.out.println(super.a);//要访问父类的，很简单super  让这个代码更容易读
        System.out.println(d);*/
    }
}
public class TestDemo2 {
    public static void main(String[] args) {
        Derived derived = new Derived();
        derived.test();
    }
}
